const axios = require('axios');

async function simpleCheckinTest() {
  try {
    console.log('=== 简单签到测试 ===');
    
    // 登录已有用户
    const loginResponse = await axios.post('http://localhost:3000/api/auth/login', {
      email: 'alice@student.com',
      password: 'password123'
    });
    
    const token = loginResponse.data.token;
    console.log('✅ 登录成功');
    
    // 尝试对活动2进行签到（假设Alice已经参与了）
    console.log('尝试对活动2进行签到...');
    
    try {
      const checkinResponse = await axios.post('http://localhost:3000/api/activities/2/checkin', {
        latitude: 39.9042,
        longitude: 116.4074,
        verification_code: 'TEST123'
      }, {
        headers: {
          'Authorization': `Bearer ${token}`,
          'Content-Type': 'application/json'
        }
      });
      
      console.log('✅ 签到成功:', checkinResponse.data);
      
    } catch (error) {
      console.log('❌ 签到失败:');
      console.log('状态码:', error.response?.status);
      console.log('错误信息:', error.response?.data);
    }
    
  } catch (error) {
    console.error('测试失败:', error.message);
  }
}

simpleCheckinTest(); 